#include <iostream>
using namespace std;
const int N = 1e5;
typedef long long ll;
ll arr[N + 1];
ll dp[N + 1];
int main()
{
    ll n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        arr[i] = x;
    }

    dp[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + arr[i];
    }

    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;;
    }
    return 0;
}
